//
//  THJMainTableViewCell.m
//  THJXHW
//
//  Created by 河南德艺 on 2017/9/13.
//  Copyright © 2017年 河南德艺. All rights reserved.
//

#import "THJMainTableViewCell.h"

@implementation THJMainTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)updateCellContentWidthDic:(NSDictionary*)dic UpdownType:(NSInteger)type btnFlag:(NSInteger)flag{
    NSLog(@"dic--%@",dic);
    NSInteger rate = [dic[@"change_n"] integerValue];
    if (rate>0) {
        [self.priceLab setTextColor:COLOR(242, 10, 8, 1)];
        [self.rateLab setBackgroundColor:COLOR(242, 10, 8, 1)];
    }else if(rate<0){
        [self.priceLab setTextColor:COLOR(79, 171, 64, 1)];
        [self.rateLab setBackgroundColor:COLOR(79, 171, 64, 1)];
    }else{
        [self.priceLab setTextColor:SingleColor(lightGrayColor)];
        [self.rateLab setBackgroundColor:SingleColor(lightGrayColor)];
    }

    self.areaLab.text = dic[@"name"];
    self.unitLab.text = @"元/吨";
    self.priceLab.text = [NSString stringWithFormat:@"%ld", [dic[@"price"] integerValue]];
    
//    if([dic[@"date"] componentsSeparatedByString:@"-"].count>=3){
//        NSString * month = [dic[@"date"] componentsSeparatedByString:@"-"][1];
//        NSString * day = [dic[@"date"] componentsSeparatedByString:@"-"][2];
//        self.dateLab.text = [NSString stringWithFormat:@"%@/%@",month,day];
//    }else{
//        self.dateLab.text = @"";
//    }
//    if(flag == 2){
//        self.rateLab.text = [NSString stringWithFormat:@"%ld", [dic[@"zd"] integerValue]];
//    }else{
        if(type == 1){
            self.rateLab.text = [NSString stringWithFormat:@"%ld", [dic[@"change_n"] integerValue]];
        }else{
            self.rateLab.text = [NSString stringWithFormat:@"%@", dic[@"change_p"]];
        }
//    }
}

@end
